/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gruppe1projekt.ModelLayer;

import java.util.*;
import java.util.ArrayList;

/**
 *
 * @author Moulde
 */
public class EmployeeContainer
{
    private static EmployeeContainer instance;
    private ArrayList<Employee> Employees;

    public static EmployeeContainer GetInstance()
    {
        if(instance == null)
            instance = new EmployeeContainer();

        return instance;
    }

    private EmployeeContainer()
    {
        Employees = new ArrayList<Employee>();
    }

    public ArrayList<Employee> getEmployees()
    {
        return Employees;
    }

    public Employee getEmployee(String username)
    {
        for (Employee employee : Employees)
        {
            if(employee.getUsername().equals(username))
            {
                return employee;
            }
        }
        
        return null;
    }

    public void setEmployees(ArrayList<Employee> Employees)
    {
        this.Employees = Employees;
    }

    public void deleteEmployee(String username)
    {
        for (int i = 0; i < Employees.size(); i++)
        {
            Employee employee = Employees.get(i);
            if (employee.getUsername().equals(username))
            {
                Employees.remove(employee);
                return;
            }
        }
    }

    public void addEmployee(Employee employee)
    {
        this.Employees.add(employee);
    }
}
